#include "Rythm.h"

// Constructor()
Rythm::Rythm(const int _Begin, const int _End, const double _Bf, const double _Hf)
	: m_Begin(_Begin)
	, m_Bf(_Bf)
	, m_Hf(_Hf)
	, m_Type(Top)
{
	m_End = (_End >= 0)? _End : m_Begin ;
}

// Destructor
Rythm::~Rythm()
{
}

// Fusion
void Rythm::Fusion(const Rythm& _R)
{
	if(_R.GetBegin() < GetBegin())
	{
		m_Begin = _R.GetBegin() ;
	}
	if(_R.GetEnd() > GetEnd())
	{
		m_End = _R.GetEnd() ;
	}
	if(_R.GetBf() < GetBf())
	{
		m_Bf = _R.GetBf() ;
	}
	if(_R.GetHf() > GetHf())
	{
		m_Hf = _R.GetHf() ;
	}
}

// =================================================================
// operator<<
std::ostream& operator<< (std::ostream& out, const Rythm* lvl)
{
	out << lvl->m_Begin << " " << lvl->m_End - lvl->m_Begin << " " ;
	switch(lvl->m_Type)
	{
		case Rythm::Top :
			out << "top " ;
			break ;
		case Rythm::Bot :
			out << "bottom " ;
			break ;
		case Rythm::Left :
			out << "left " ;
			break ;
		case Rythm::Right :
			out << "right " ;
			break ;
		default :
			out << "top " ;
			break ;
	}
	out << "30" ;
	return out ;
}